/*----------------------------------------------------------------------------------------
*
*  Copyright 2019, Gao Hai Hui, <fromzeropoint@126.com>.  All rights reserved.
*  https://gitee.com/helloworldghh/xoskit.git
*  Use of this source code is governed by a MIT license
*  that can be found in the License file.
*
----------------------------------------------------------------------------------------*/
#ifndef __93143A1D_B320_4daf_933B_F48BF59FE72F__
#define __93143A1D_B320_4daf_933B_F48BF59FE72F__

#include "../tools/head.h"

/////////////////////////////////////////////////////////////////////////////////////////
// 

namespace xos_aio
{
    // 
    // 
    // 
    class aio_data;

    // 
    // overlapped ex
    // 
    struct OverlappedEx
    {
        WSAOVERLAPPED m_ov;
        aio_data * m_pAioData;
    };

    // 
    // 
    // 
    class aio_data : public xos_stl::mem_item< aio_data, thread_lock >
    {
    public:
        typedef aio_data T;

    public:
        //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        // 
        static int get_xos_item_data( ITEM_DATA*& item_ptr );

    public:
        aio_data();
        ~aio_data();

    public:
        int m_nType;

        xos_box::i_msg * m_lpMsgData;

        OverlappedEx m_ov_ex;
        DWORD m_dwFlags;
        DWORD m_dwBytes;

        sockaddr_storage m_addr;
        int m_nAddrLen;

        DWORD m_dwErrCode;

    protected:
        int init_data();

    public:
        int init();
        int term();

    public:
        int release();

    };
} // xos_aio

#endif // __93143A1D_B320_4daf_933B_F48BF59FE72F__
